import java.io.IOException;

public class Main{

	/**
	 * @param args
	 * @throws IOException
	 * @throws NumberFormatException
	 */
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		java.io.BufferedReader r = new java.io.BufferedReader(
				new java.io.InputStreamReader(System.in));

		int number = -1;
		int[] perms;
		while (true) {
			number = Integer.parseInt(r.readLine());
			if (number == 0) {
				break;
			} else {
				perms = new int[number];
				String[] s = (r.readLine().trim()).split(" ");
				for (int i = 0; i < perms.length; i++) {
					perms[i] = Integer.parseInt(s[i]);
				}
				String result = "ambiguous";
				for (int i = 0; i <= perms.length / 2; i++) {
					if ((i + 1) != perms[perms[i]-1]) {
						result = "not ambiguous";
						break;
					}
				}
				System.out.println(result);
			}
		}
	}
}
